﻿using AutoMapper;
using commodity.Dtos;
using commodity.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace commodity.Profiles
{
    public class GoodsProfile:Profile
    {
        public GoodsProfile() 
        {
            CreateMap<Goods, GoodsDto>();
            CreateMap<AddGoodsDto, Goods>()
                .ForMember(
                desp => desp.CommodityId,
                opt => opt.MapFrom(src => src.goods_Cat)
                ).ForMember(
                desp => desp.CreateTime,
                opt => opt.MapFrom(src => DateTime.UtcNow)
                ).ForMember(
                desp => desp.UpdateTime,
                opt => opt.MapFrom(src => DateTime.UtcNow)
                ).ForMember(
                desp => desp.Goods_Price,
                opt => opt.MapFrom(src => src.goods_Price)
                ).ForMember(
                desp => desp.Goods_Name,
                opt => opt.MapFrom(src => src.goods_Name)
                ).ForMember(
                desp => desp.Goods_Number,
                opt => opt.MapFrom(src => src.goods_Number)
                );
            CreateMap<string, GoodsPicture>()
                .ForMember(
                desp => desp.Path,
                opt => opt.MapFrom(src => src)
                );
            CreateMap<AddGoodsInformationDto, GoodsInformation>()
                .ForMember(
                desp => desp.PropertyName,
                opt => opt.MapFrom(src => src.PropertyName)
                ).ForMember(
                desp => desp.state,
                opt => opt.MapFrom(src => src.State)
                ).ForMember(
                desp => desp.Value,
                opt => opt.MapFrom(src => src.Value)
                );
        }
    }
}
